package cn.edu.sjtu.se.dslab.component.aadl;

import java.util.List;
import java.util.Map;
/**
 * 从aadl图中提取的aadl线程类
 * @author sunke
 *
 */
public class AADLThread {
	/**
	 * 线程的名称
	 */
	private String name;
	/**
	 * 该端口与哪一个AADLNode相连
	 */
	private Map<AADLFeature, PortPair> connections;
	
	private List<AADLFeature> ports;
	
	/**
	 * 所属的设备 可以通过具体的db_id对应设备 ;
	 */
	private AADLNode parentNode;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public AADLNode getParentNode() {
		return parentNode;
	}

	public void setParentNode(AADLNode parentNode) {
		this.parentNode = parentNode;
	}

	public Map<AADLFeature, PortPair> getConnections() {
		return connections;
	}

	public void setConnections(Map<AADLFeature, PortPair> connections) {
		this.connections = connections;
	}

	public List<AADLFeature> getPorts() {
		return ports;
	}

	public void setPorts(List<AADLFeature> ports) {
		this.ports = ports;
	}

	@Override
	public String toString() {
		StringBuffer temp = new StringBuffer();
		if (ports != null) {
			for (AADLFeature feature:ports) {
				temp.append("port: "+feature.getName()+"\n");
			}
		}
		
		if (connections != null) {
			for (AADLFeature feature : connections.keySet()) {
				temp.append("from "+feature.getName()+" to "+connections.get(feature).toString()+"\n");
			}
		}
		 
		return "AADLThread [name=" + name + ", connections=" + temp.toString()
				+  ", parentNode=" + parentNode.getName() + "]";
	}

}
